{{ define "PostHtml/item2.html"}}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<h1>用户添加页面</h1>
<form>
    用户名：<input type="text" id="username"> <br>
    密&nbsp;&nbsp;&nbsp;码：<input type="password" id="password"> <br>
    年&nbsp;&nbsp;&nbsp;龄：<input type="text" , id="age"> <br>


    <input type="button" value="提交" id="add_btn">
</body>
<script>
    let add_btn = document.getElementById("add_btn")
    add_btn.onclick = function () {
        let username = document.getElementById("username").value;
        let password = document.getElementById("password").value;
        let age = document.getElementById("age").value;
        $.ajax({
            url: "/add_data3",
            type: "POST",
            data: {
                "username": username,
                "password": password,
                "age": age,
            },
            success: function (data) {
                alert("数据提交成功！", data["msg"]);
            },
            fail: function (err) {
                console.log(err);
            }
        })

    }
</script>
</html>
{{end}}